<?php

// auteur : zulad

    require_once (DIR_INCLUDE.'/sajax.inc.php');
    function getAmi($type)
    {
        global $pdo;
        
        switch($type)
        {
            case 'amiConnecte':
                $sql = 'SELECT * FROM forum_amis, forum_whosonline WHERE (forum_whosonline.membre_id=ami_to) AND ami_confirm="1" AND (ami_ignore != "1" OR ami_ignore IS NULL) AND (ami_from='.$_SESSION['id'].') GROUP BY ami_to';
                $q = $pdo->query($sql);
                $value = $type."-2-2-";
				if($q->rowCount() < 1)
					$value .= 'Vous n\'avez pas d\'amis connecté.';
				else {
						
						$searchTab = array();
		
				        foreach($q as $v)
		                {
							if($v['ami_to'] == $_SESSION['id'])
								$ami = $v['ami_from'];
							else
								$ami = $v['ami_to'];
							
							$membreInfo = $pdo->prepare('SELECT membre_id,membre_prenom,membre_localisation FROM forum_membres WHERE membre_id=?');
		$membreInfo->execute(array($ami));
		$minfo = $membreInfo->fetch(PDO::FETCH_OBJ);

                    // données additionnelles
                    $img = ''.GetAvatarInscritById($ami);
					$add='<hr />Pr&eacute;nom : ' . $minfo->membre_prenom . '<hr />&Acirc;ge : ' . GetAgeById($ami). '<hr />Ville : ' 
					. GetVilleById(GetValueFromQuery('SELECT membre_departement AS value FROM forum_membres WHERE membre_id='.$ami));
                    
		    if(is_numeric($ami) && (!is_numeric(array_search($ami,$searchTab))))
				$value .= "<div class=\"cadre_membre_inscrit\"><div class=\"cadre_transparent\"><div class=\"avatar_inscrit\">".$img."</div><div class=\"info_inscrit\">".sex2color(id2pseudo($ami),$ami).$add.'</div></div><div class="ville_inscrit">ville</div></div>';
							 
							array_push($searchTab,$ami);
		                }
				
        		}
				
                break;
                
            case 'amiDeconnecte':
                $sql = 'SELECT * FROM forum_amis, forum_whosonline WHERE (forum_whosonline.membre_id!=ami_to) AND ami_confirm="1" AND (ami_ignore != "1" OR ami_ignore IS NULL) AND (ami_from='.$_SESSION['id'].') GROUP BY ami_to';
                $q = $pdo->query($sql);
                $value = $type."-2-2-";
				if($q->rowCount() < 1)
					$value .= '';
				else {
						
						$searchTab = array();
		
				        foreach($q as $v)
		                {
							if($v['ami_to'] == $_SESSION['id'])
								$ami = $v['ami_from'];
							else
								$ami = $v['ami_to'];
							
							$membreInfo = $pdo->prepare('SELECT membre_id,membre_prenom,membre_localisation FROM forum_membres WHERE membre_id=?');
		$membreInfo->execute(array($ami));
		$minfo = $membreInfo->fetch(PDO::FETCH_OBJ);

                    // données additionnelles
                    $img = ''.GetAvatarInscritById($ami);
					$add='<hr />Pr&eacute;nom : ' . $minfo->membre_prenom . '<hr />&Acirc;ge : ' . GetAgeById($ami). '<hr />Ville : ' 
					. GetVilleById(GetValueFromQuery('SELECT membre_departement AS value FROM forum_membres WHERE membre_id='.$ami));
                    
		    if(is_numeric($ami) && (!is_numeric(array_search($ami,$searchTab))))
				$value .= "<div class=\"cadre_membre_inscrit\"><div class=\"cadre_transparent\"><div class=\"avatar_inscrit\">".$img."</div><div class=\"info_inscrit\">".sex2color(id2pseudo($ami),$ami).$add.'</div></div><div class="ville_inscrit">ville</div></div>';
							 
							array_push($searchTab,$ami);
		                }
				
        		}
				
                break;  
            case 'commun':
                $sql = 'SELECT * FROM forum_amis WHERE ami_from = '.$_SESSION["id"].' GROUP BY ami_to';
                $q = $pdo->query($sql);
                $value = $type."-2-2-";
				if($q->rowCount() < 1)
					$value = 'Vous n\'avez pas d\'amis.';
				else {
					$searchTab = array();
				
                foreach($q as $v)
                {
					$sql = 'SELECT ami_from FROM forum_amis WHERE ami_to != '.$_SESSION["id"].' AND ami_to ='.$v['ami_to'].' GROUP BY ami_to';
                $q2 = $pdo->query($sql);
                if($q2->rowCount() > 0)
					foreach($q2 as $v2)
					{
                    	$membreInfo = $pdo->prepare('SELECT membre_id,membre_prenom,membre_localisation FROM forum_membres WHERE membre_id=?');
						$membreInfo->execute(array($v2['ami_from']));
						$minfo = $membreInfo->fetch(PDO::FETCH_OBJ);

                   		 // données additionnelles
                    	$img = ''.GetAvatarInscritById($v2['ami_from']);
						$add='<hr />Pr&eacute;nom : ' . $minfo->membre_prenom . '<hr />&Acirc;ge : ' . GetAgeById($v2['ami_from']). '<hr />Ville : ' 
					. GetVilleById(GetValueFromQuery('SELECT membre_departement AS value FROM forum_membres WHERE membre_id='.$v2['ami_from']));
                    
		    			if(is_numeric($v2['ami_from']) && (!is_numeric(array_search($v2['ami_from'],$searchTab))))
							$value .= "<div class=\"cadre_membre_inscrit\"><div class=\"cadre_transparent\"><div class=\"avatar_inscrit\">".$img."</div><div class=\"info_inscrit\">".sex2color(id2pseudo($v2['ami_from']),$v2['ami_from']).$add.'</div></div><div class="ville_inscrit">ville</div></div>';
							 
						array_push($searchTab,$v2['ami_from']);
					}
                }
        }
				
                break;
                
            case 'ignore':
                $sql = 'SELECT * FROM forum_amis WHERE (ami_confirm="1" OR ami_confirm="0") AND ami_ignore = "1" AND (ami_from='.$_SESSION['id'].') GROUP BY ami_to';
                $q = $pdo->query($sql);
                $value = $type."-2-2-";
        		if($q->rowCount() < 1)
					$value .= 'Vous n\'avez pas encore ignoré d\'amis.';
						else {

				$searchTab = array();
                foreach($q as $v)
                {
					
					if($v['ami_to'] == $_SESSION['id'])
						$ami = $v['ami_from'];
					else
						$ami = $v['ami_to'];
						
				$membreInfo = $pdo->prepare('SELECT membre_id,membre_prenom,membre_localisation FROM forum_membres WHERE membre_id=?');
		$membreInfo->execute(array($ami));
		$minfo = $membreInfo->fetch(PDO::FETCH_OBJ);

                    // données additionnelles
                    $img = ''.GetAvatarInscritById($ami);
					$add='<hr />Pr&eacute;nom : ' . $minfo->membre_prenom . '<hr />&Acirc;ge : ' . GetAgeById($ami). '<hr />Ville : ' 
					. GetVilleById(GetValueFromQuery('SELECT membre_departement AS value FROM forum_membres WHERE membre_id='.$ami));
                    
		    if(is_numeric($ami) && (!is_numeric(array_search($ami,$searchTab))))
				$value .= "<div class=\"cadre_membre_inscrit\"><div class=\"cadre_transparent\"><div class=\"avatar_inscrit\">".$img."</div><div class=\"info_inscrit\">".sex2color(id2pseudo($ami),$ami).$add.'</div></div>';
							 
							array_push($searchTab,$ami);
                }
								
        }
					
					
                break;
            
            case 'aValider':
                $sql = 'SELECT * FROM forum_amis WHERE ami_confirm="0" AND (ami_ignore != "1" OR ami_ignore IS NULL) AND (ami_from='.$_SESSION["id"].') GROUP BY ami_to';
                $q = $pdo->query($sql);
                $value = $type."-2-2-";
                
                if($q->rowCount() < 1)
					$value .= 'Vous n\'avez pas de lien d\'amitié à valider.';
				else {
					$searchTab = array();
	                foreach($q as $v)
	                {
						if($compteur > 0 && $compteur%$mod==0)
							$value .= '</tr><tr>';
						
						if($v['ami_to'] == $_SESSION['id'])
							$ami = $v['ami_from'];
						else
							$ami = $v['ami_to'];
				$membreInfo = $pdo->prepare('SELECT membre_id,membre_prenom,membre_localisation FROM forum_membres WHERE membre_id=?');
		$membreInfo->execute(array($ami));
		$minfo = $membreInfo->fetch(PDO::FETCH_OBJ);

                    // données additionnelles
                    $img = ''.GetAvatarInscritById($ami);
					$add='<hr />Pr&eacute;nom : ' . $minfo->membre_prenom . '<hr />&Acirc;ge : ' . GetAgeById($ami). '<hr />Ville : ' 
					. GetVilleById(GetValueFromQuery('SELECT membre_departement AS value FROM forum_membres WHERE membre_id='.$ami));
                    
		    if(is_numeric($ami) && (!is_numeric(array_search($ami,$searchTab))))
				$value .= "<div class=\"cadre_membre_inscrit\"><div class=\"avatar_inscrit\">".$img."</div><div class=\"info_inscrit\">".sex2color(id2pseudo($ami),$ami).$add.'</div></div>';
							 
							array_push($searchTab,$ami);
						}
	                }
				
				
                break;
        }
        
        return $value;
    }
    
    function setAmi($command)
    {
        global $pdo;
        
        $command = explode('-',$command);
        
        if($command[0])
            $pdo->query('UPDATE forum_amis SET ami_confirm='.$command[0].' WHERE ami_from='.$command[1].' AND ami_to='.$command[2]);
        else
            $pdo->query('DELETE FROM forum_amis WHERE ami_from='.$command[1].' AND ami_to='.$command[2]);
        
        return sex2color(id2sex($command[2]),$command[2]) . ' a été ' . ($command[0]?'ajouté':'rejeté');
        
    }
    
  

	function getFriendList($confirmed)
	{
		global $pdo;
		$confirmed = ($confirmed) ? '1' : '0';
			$req = $pdo->prepare("SELECT ami_date as date, ami_to,ami_from,ami_id,fm.membre_pseudo as name FROM forum_amis JOIN forum_membres as fm ON fm.membre_id=ami_to OR fm.membre_id=ami_from WHERE (ami_to=? OR ami_from=?) AND ami_confirm=? GROUP BY ami_id");
			$req->execute(array($_SESSION['id'],$_SESSION['id'],$confirmed));
			
		return $req;
	}
    
// ici on affiche un texte en hut de la page pour le changer c'esty dans modules/message_haut.php
echo '' . Friends . '';




    sajax_init();
    //$sajax_debug_mode = 1;
    sajax_export("getAmi","setAmi");
    sajax_handle_client_request();
    
    echo 	'<script>'
    		.sajax_get_javascript()
			.'</script>';
    
echo '<div class="container_menue parente">
      <div id="t_container_1" class="container_transparent container_visible" onclick="montre(\'container_1\');">Amis (0)</div>
	  <div id="t_container_2" class="container_transparent" onclick="montre(\'container_2\');">Amis en commun (0)</div>
	  <div id="t_container_3" class="container_transparent" onclick="montre(\'container_3\');">Amis ignorer (0)</div>
	  <div id="t_container_4" class="container_transparent" onclick="montre(\'container_4\');">Amis en cours (0)</div>
      </div>
	  
      <div id="container_1" style="display:block">
      <div class="sous_container_border_top"></div>
      <div class="sous_container_border_bottom8"></div>
      <div class="sous_container_border_left"></div>
	  <div class="container_menue parente">
	  <div id="t_container-1-1_1" class="sous_container_transparent sous_container_visible" onclick="montre(\'container-1-1_1\');">Amis connecté (0)</div>
	  <div id="t_container-1-1_2" class="sous_container_transparent" onclick="montre(\'container-1-1_2\');">Amis déconnecté (0)</div>
	  </div>

      <div id="container-1-1_1" style="display:block">
      <div class="sous_container_border_top"></div>
      <div class="sous_container_border_bottom9"></div>
      <div class="sous_container_border_left"></div>
	  <div class="container_menue parente">
	  <div id="t_container-1-1-1_1" class="sous_container_transparent sous_container_visible" onclick="montre(\'container-1-1-1_1\');">Homme(0)</div>
	  <div id="t_container-1-1-1_2" class="sous_container_transparent" onclick="montre(\'container-1-1-1_2\');">Femme (0)</div>
	  </div>

      <div id="container-1-1-1_1" style="display:block">
	  <div class="sous_contenu_membre">
	  page homme
	  </div>
	  </div>

      <div id="container-1-1-1_2" style="display:none">
	  <div class="sous_contenu_membre">
      page femme
	  </div>
	  </div>

	  </div>

      <div id="container-1-1_2" style="display:none">
      <div class="sous_container_border_top"></div>
      <div class="sous_container_border_bottom9"></div>
      <div class="sous_container_border_left"></div>
	  <div class="container_menue parente">
	  <div id="t_container-1-1-2_1" class="sous_container_transparent sous_container_visible" onclick="montre(\'container-1-1-2_1\');">Homme(0)</div>
	  <div id="t_container-1-1-2_2" class="sous_container_transparent" onclick="montre(\'container-1-1-2_2\');">Femme (0)</div>
	  </div>

      <div id="container-1-1-2_1" style="display:block">
	  <div class="sous_contenu_membre">
	  page homme
	  </div>
	  </div>

      <div id="container-1-1-2_2" style="display:none">
	  <div class="sous_contenu_membre">
      page femme
	  </div>
	  </div>



	  </div>

	  
	  </div>

      <div id="container_2" style="display:none">
      <div class="sous_container_border_top"></div>
      <div class="sous_container_border_bottom8"></div>
      <div class="sous_container_border_left"></div>
	  <div class="container_menue parente">
	  <div id="t_container-1-2_1" class="sous_container_transparent sous_container_visible" onclick="montre(\'container-1-2_1\');">Amis connecté (0)</div>
	  <div id="t_container-1-2_2" class="sous_container_transparent" onclick="montre(\'container-1-2_2\');">Amis déconnecté (0)</div>
	  </div>

      <div id="container-1-2_1" style="display:block">
      <div class="sous_container_border_top"></div>
      <div class="sous_container_border_bottom9"></div>
      <div class="sous_container_border_left"></div>
	  <div class="container_menue parente">
	  <div id="t_container-1-2-1_1" class="sous_container_transparent sous_container_visible" onclick="montre(\'container-1-2-1_1\');">Homme(0)</div>
	  <div id="t_container-1-2-1_2" class="sous_container_transparent" onclick="montre(\'container-1-2-1_2\');">Femme (0)</div>
	  </div>

      <div id="container-1-2-1_1" style="display:block">
	  <div class="sous_contenu_membre">
	  page homme
	  </div>
	  </div>

      <div id="container-1-2-1_2" style="display:none">
	  <div class="sous_contenu_membre">
      page femme
	  </div>
	  </div>

	  </div>

      <div id="container-1-2_2" style="display:none">
      <div class="sous_container_border_top"></div>
      <div class="sous_container_border_bottom9"></div>
      <div class="sous_container_border_left"></div>
	  <div class="container_menue parente">
	  <div id="t_container-1-2-2_1" class="sous_container_transparent sous_container_visible" onclick="montre(\'container-1-2-2_1\');">Homme(0)</div>
	  <div id="t_container-1-2-2_2" class="sous_container_transparent" onclick="montre(\'container-1-2-2_2\');">Femme (0)</div>
	  </div>

      <div id="container-1-2-2_1" style="display:block">
	  <div class="sous_contenu_membre">
	  page homme
	  </div>
	  </div>

      <div id="container-1-2-2_2" style="display:none">
	  <div class="sous_contenu_membre">
      page femme
	  </div>
	  </div>



	  </div>

	  </div>

      <div id="container_3" style="display:none">
      <div class="sous_container_border_top"></div>
      <div class="sous_container_border_bottom8"></div>
      <div class="sous_container_border_left"></div>
	  <div class="container_menue parente">
	  <div id="t_container-1-3_1" class="sous_container_transparent sous_container_visible" onclick="montre(\'container-1-3_1\');">Amis connecté (0)</div>
	  <div id="t_container-1-3_2" class="sous_container_transparent" onclick="montre(\'container-1-3_2\');">Amis déconnecté (0)</div>
	  </div>

      <div id="container-1-3_1" style="display:block">
      <div class="sous_container_border_top"></div>
      <div class="sous_container_border_bottom9"></div>
      <div class="sous_container_border_left"></div>
	  <div class="container_menue parente">
	  <div id="t_container-1-3-1_1" class="sous_container_transparent sous_container_visible" onclick="montre(\'container-1-3-1_1\');">Homme(0)</div>
	  <div id="t_container-1-3-1_2" class="sous_container_transparent" onclick="montre(\'container-1-3-1_2\');">Femme (0)</div>
	  </div>

      <div id="container-1-3-1_1" style="display:block">
	  <div class="sous_contenu_membre">
	  page homme
	  </div>
	  </div>

      <div id="container-1-3-1_2" style="display:none">
	  <div class="sous_contenu_membre">
      page femme
	  </div>
	  </div>

	  </div>

      <div id="container-1-3_2" style="display:none">
      <div class="sous_container_border_top"></div>
      <div class="sous_container_border_bottom9"></div>
      <div class="sous_container_border_left"></div>
	  <div class="container_menue parente">
	  <div id="t_container-1-3-2_1" class="sous_container_transparent sous_container_visible" onclick="montre(\'container-1-3-2_1\');">Homme(0)</div>
	  <div id="t_container-1-3-2_2" class="sous_container_transparent" onclick="montre(\'container-1-3-2_2\');">Femme (0)</div>
	  </div>

      <div id="container-1-3-2_1" style="display:block">
	  <div class="sous_contenu_membre">
	  page homme
	  </div>
	  </div>

      <div id="container-1-3-2_2" style="display:none">
	  <div class="sous_contenu_membre">
      page femme
	  </div>
	  </div>



	  </div>


	  </div>

      <div id="container_4" style="display:none">
      <div class="sous_container_border_top"></div>
      <div class="sous_container_border_bottom8"></div>
      <div class="sous_container_border_left"></div>
	  <div class="container_menue parente">
	  <div id="t_container-1-4_1" class="sous_container_transparent sous_container_visible" onclick="montre(\'container-1-4_1\');">Amis connecté (0)</div>
	  <div id="t_container-1-4_2" class="sous_container_transparent" onclick="montre(\'container-1-4_2\');">Amis déconnecté (0)</div>
	  </div>

      <div id="container-1-4_1" style="display:block">
      <div class="sous_container_border_top"></div>
      <div class="sous_container_border_bottom9"></div>
      <div class="sous_container_border_left"></div>
	  <div class="container_menue parente">
	  <div id="t_container-1-4-1_1" class="sous_container_transparent sous_container_visible" onclick="montre(\'container-1-4-1_1\');">Homme(0)</div>
	  <div id="t_container-1-4-1_2" class="sous_container_transparent" onclick="montre(\'container-1-4-1_2\');">Femme (0)</div>
	  </div>

      <div id="container-1-4-1_1" style="display:block">
	  <div class="sous_contenu_membre">
	  page homme
	  </div>
	  </div>

      <div id="container-1-4-1_2" style="display:none">
	  <div class="sous_contenu_membre">
      page femme
	  </div>
	  </div>

	  </div>

      <div id="container-1-4_2" style="display:none">
      <div class="sous_container_border_top"></div>
      <div class="sous_container_border_bottom9"></div>
      <div class="sous_container_border_left"></div>
	  <div class="container_menue parente">
	  <div id="t_container-1-4-2_1" class="sous_container_transparent sous_container_visible" onclick="montre(\'container-1-4-2_1\');">Homme(0)</div>
	  <div id="t_container-1-4-2_2" class="sous_container_transparent" onclick="montre(\'container-1-4-2_2\');">Femme (0)</div>
	  </div>

      <div id="container-1-4-2_1" style="display:block">
	  <div class="sous_contenu_membre">
	  page homme
	  </div>
	  </div>

      <div id="container-1-4-2_2" style="display:none">
	  <div class="sous_contenu_membre">
      page femme
	  </div>
	  </div>



	  </div>

	  </div>



	
	  
	  
	  
	  
	  
	  ';

              
        $table = '';

        
        $j = false;$i=0;
        $data = getFriendList(false);
		/*
	while($friend_nc = $data->fetch()){
              $i++;
		if($friend_nc['ami_to'] != $_SESSION['id'])
			$id = $friend_nc['ami_to'];
		else
			$id = $friend_nc['ami_from'];
		
			$pseudo = sex2color(id2sex($id),$id);
			
			if($friend_nc['ami_from'] == $_SESSION['id'])
                            $action = '<a onclick="do_setAmi(\''.$i.'\',\'1-'.$friend_nc['ami_from'].'-'.$friend_nc['ami_to'].'\');" style="cursor:pointer;">Accepter la demande</a> | <a onclick="do_setAmi(\''.$i.'\',\'0-'.$friend_nc['ami_from'].'-'.$friend_nc['ami_to'].'\');" style="cursor:pointer;">Refuser la demande</a>';
		$table .= '<tr id="_'.($i).'">
                                <td>' . GetAvatarInscritById($id) . $pseudo . '</td>
                                <td>' . format_temps($friend_nc['date']) . '</td>
                                <td>' . $action . '</td>
                           </tr>';
		$j = true;
        }

        if(!$j){
            $table .= '
            <tr>
                    <td colspan="3">Aucune demande d\'amitié pour le moment</td>
            </tr>';
        }
	*/
			if(isset($_GET['cmd']) && isset($_GET['aID'])){
				if($_GET['cmd'] == 'accept_ami'){
					$query = $pdo->prepare('SELECT * FROM forum_amis WHERE ami_id=?');
					$query->execute(array($_GET['aID']));
						
						if($query->rowCount() > 0){
							$data = $query->fetch();
							$pdo->query("SET NAMES UTF8");
							$query = $pdo->prepare("UPDATE forum_amis SET ami_confirm='1' WHERE ami_id=?");
							$query->execute(array($_GET['aID']));
							
							$pdo->query("SET NAMES UTF8");
							sendMp($data['ami_from'],"Demande d'amitié accepté","Bonjour ". sex2color(id2sex($data['ami_from']),$data['ami_from'])."\nLe membre ".  sex2color(id2sex($data['ami_to']),$data['ami_to']). " à accepté de faire parti de vos amis\nVous et lui êtes maintenant ami.");
								header("location:".getLienModule("membre","friendlist"));	
						}else{
							redirect("Erreur : ID de la demande d'amitié innexistante !",getLienModule("membre","friendlist"));	
						}
						
				}
				
				else if($_GET['cmd'] == 'ignore_ami'){
					$query = $pdo->prepare('SELECT * FROM forum_amis WHERE ami_id=? AND ami_confirm="1"');
					$query->execute(array($_GET['aID']));
						
						if($query->rowCount() > 0){
							$data = $query->fetch();
							$pdo->query("SET NAMES UTF8");
							$query = $pdo->prepare("UPDATE forum_amis SET ami_ignore='1' WHERE ami_id=?");
							$query->execute(array($_GET['aID']));
							
							$pdo->query("SET NAMES UTF8");
							//sendMp($data['ami_from'],"Demande d'amitié accepté","Bonjour ". sex2color(id2sex($data['ami_from']),$data['ami_from'])."\nLe membre ".  sex2color(id2sex($data['ami_to']),$data['ami_to']). " à accepté de faire parti de vos amis\nVous et lui êtes maintenant ami.");
								header("location:".getLienModule("membre","friendlist"));	
						}else{
							redirect("Erreur : ID de la demande d'amitié innexistante ou vous ne pouvez ignorer un membre qui n'est pas votre ami !",getLienModule("membre","friendlist"));	
						}
						
				}
				
				else if($_GET['cmd'] == 'delete_ami'){
					$query = $pdo->prepare('SELECT * FROM forum_amis WHERE ami_id=? AND ami_confirm="1"');
					$query->execute(array($_GET['aID']));
						
						if($query->rowCount() > 0){
							$data = $query->fetch();
							$pdo->query("SET NAMES UTF8");
							$query = $pdo->prepare("DELETE FROM forum_amis WHERE ami_id=?");
							$query->execute(array($_GET['aID']));
							
							$pdo->query("SET NAMES UTF8");
							
							if($data['ami_from']!=$_SESSION['id'])
								$ami = $data['ami_from'];
							else
								$ami = $data['ami_to'];
								
							sendMp($ami,"Amitié supprimé","Bonjour ". sex2color(id2sex($ami),$ami)."\nLe membre ".  sex2color(id2sex($_SESSION['id']),$_SESSION['id']). " vous à supprimé de sa liste d'amis\nVous et lui n'êtes maintenant plus ami.");
								header("location:".getLienModule("membre","friendlist"));	
						}else{
							redirect("Erreur : ID de la demande d'amitié innexistante ou vous ne pouvez pas supprimer un ami qui n'a pas encore accepté votre demande d'amitié !",getLienModule("membre","friendlist"));	
						}
						
				}else
					redirect("Commande non reconnue !",getLienModule("membre","friendlist"));	
				
			}
			
        if($j)
        {
                echo $table . "\n</tbody></table>";
        }
       
        echo '<script type="text/javascript">

                window.onload = function()
                {
                	do_getAmi("amiConnecte");
                	do_getAmi("amiDeconnecte");
                	do_getAmi("commun");
                    do_getAmi("ignore");
                    do_getAmi("aValider");
                    
                }

            </script>';